package com.usian.three.lister;

import cn.hutool.core.util.RandomUtil;
import com.usian.three.utils.AlidayuUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * 文件名:CodeLister
 * 创建者: 闫俊涛
 * 创建时间:2022/6/29 13:09
 * 描述:这是一个实例
 */
@Service
public class SendCodeLister {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @RabbitListener(queues = "java.first.queue")
    public  void  login(Message message, String phone) throws Exception {
        AlidayuUtils alidayuUtils = new AlidayuUtils();

        int code = RandomUtil.randomInt(1000, 9999);
     /*   alidayuUtils.goToLogin(phone,code+"");*/
        stringRedisTemplate.opsForValue().set(phone,code+"");
        stringRedisTemplate.expire(phone,5, TimeUnit.DAYS);
        System.out.println("短信发送完毕");
    }

}
